<?php 
// Header
$this->left_menu = 'menu/'.$this->params['controller'];
$params = array(
	//'root'	=>	$this->params['named']['root']
);
if (isset($this->params['plugin'])) {
	$params['plugin'] = $this->params['plugin'];
} else {
	$params['plugin'] = null;
}
if (isset($this->params['named']['root'])) {
	$params['root'] = $this->params['named']['root']; 
}

// Load CSS
echo $this->Html->css('manage_categories/add.css');
echo $this->Html->css('cake.form');

// Load Javascript
echo $this->Html->script('ckeditor/ckeditor_basic');
?>

<div class='right_content'>
<div class="title_left_sidebar">
	<div class="text_title">
		<?php __("Edit Category")?>
	</div>
	<div class="create_edit">
		<div class="bd_title"></div>
		<div class="item_create">
			<div class="item_menu"><?php echo $html->image('toolbar/add.png', array('alt'=>__('List Of Categories',true), 'align'=>'left')) ?></div>
			<div class="category_mn"><a id='add_facility_link' href="<?php echo $html->url($params + array('controller'=> $this->params['controller'], 'action'	=>	'index'))?>"><?php __("List Of Categories")?></a></div>
			<div class="clear"></div>
		</div>
		<div class="bd_title"></div>
	</div>
</div>

<?php echo $session->flash()?>

<div class='cake_form'>
<?php 
echo $form->create($categoryModel['name'], array(
	'url'	=>	$params + array(
		'controller'	=>	$this->params['controller'],	
		'action'		=>	'edit'
	),
	'id'		=>	'add_category_form',
	'enctype'	=>	'multipart/form-data'
));
echo $form->input('id');
echo $form->input('name', array(
	'label'	=>	__("Name: ", true),
	'error'	=>	__("Category name can't be left blank", true)
));

if ($configs['ManageCategory']['edit']['show_alias']) {
	echo $form->input('alias', array('label'	=>	__("Alias: ", true)));
} else {
	echo $form->input('alias', array('label'	=>	__("Alias: ", true), 'type' => 'hidden'));
}

if (!isset($configs['Category']['deep']) || $configs['Category']['deep'] > 1) {
	echo $form->input('parent_id', array('label'	=>	__("Parent Category: ", true), 'options'	=>	$tree));
}

$image = $this->data[$categoryModel['name']]['image'];
if ($image != "") {
	$ext = strrchr($image, ".");
	$pos = strrpos($image, ".");
	$filename = substr($image,0,$pos);
	$image = $filename."_thumbnail".$ext;
}

if ($configs['Category']['image']['show']):
$options = array(
	'name'				=>	$image,
	'path'				=>	$configs['Category']['thumbnail']['uri'],
	'field_name'		=>	'image',
	'label'				=>	__('Image',true),
	'legend_title'		=>	__('Image',true),
	'delete_image_link'	=>	$html->url($params + array('controller'=> $this->params['controller'], 'action'=>'delete_image', 'category_id'	=>	$this->data[$categoryModel['name']]['id']))
	//'/categories/manage_news/delete_image/'.$this->data['Article']['id'])
);
echo $html->form_image($options,array());
endif;
?>

<div class="input">
<table cellpadding='0' cellspacing='0' border='0' width='100%'>
<tr>
	<td class='label' valign='top'><?php __("Description: ")?></td>
	<td>
		<?php
		echo $form->input('description', array('label'	=>	false, 'div'=>false)); 
		echo $wysiwyg->render("{$categoryModel['name']}.description", 'ckeditor', array('uiColor'=>'#97da7f'));
		?>
	</td>
</tr>
</table>
</div>
<?php
echo $form->end(__('Update Category', true));
?>
</div>
</div>